<!-- SKU详情 - 综合表单页面 -->
<template>
  <div class="page-container">
    <el-form id="page_order_create" ref="form" :model="form" :rules="rules" v-loading="loading"
      class="standard_form_gird standard_form_gird_right" label-position="right" label-width="140px"
      style="margin-bottom: 90px;">

      <ex_header_spiler :title="$tt('label_customer_info')" v-if="!isCustomerSystem"></ex_header_spiler>

      <el-row v-if="!isCustomerSystem">
        <el-col>
          <el-form-item :label="$tt('label_customer', '客户')" prop="customerId" key="customerId">
            <common_customer_choose v-model="form.customerId"
              :currentLabel="form.customerId ? $formatNameCode(form.customerName, form.customerCode) : null"
              @changeItem="customerChange" :disabled="edit" style="width: 100%;"></common_customer_choose>

          </el-form-item>
        </el-col>
      </el-row>
      <ex_header_spiler :title="$tt('label_base_info')"></ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_name_cn', '中文名称')" prop="skuName">
            <ex_super_input v-model="form.skuName" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_name_en', '英文名称')" prop="skuNameEn">
            <ex_super_input v-model="form.skuNameEn" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_code', '商品条形码')" prop="skuBarcode">
            <ex_super_input v-model="form.skuBarcode" :disabled="edit"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item :label="$tt('label_sku_code_cn', '自定义商品编码')" prop="customNumber">
            <ex_super_input v-model="form.skuCode" />
          </el-form-item>
        </el-col>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item :label="$tt('label_sku_unit')" prop="skuUnit">
            <ex_super_input v-model="form.skuUnit" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_unit_price')" prop="skuPrice">
            <div style="display: flex; gap: 8px;">
              <ex_super_input v-model="form.skuPrice" class="w_fill" />
              <FmsCurrencyChoose :value="form.currencyCode" @input="changeCurrency" @initList="initCurrency">
              </FmsCurrencyChoose>
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item :label="$tt('label_categ_info', '商品品类')" prop="categId">
            <sku_categ_cascader v-if="sku_categ_cascader" :categList.sync="form.categList" :categId.sync="form.categId"
              @all_categ="allCateg" style="width: 100%;" />
          </el-form-item>
        </el-col>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item :label="$tt('label_provenance')" prop="skuOrigin">
            <ex_super_input v-model="form.skuOrigin" />
          </el-form-item>
        </el-col>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item :label="$tt('label_material')" prop="skuMaterial">
            <ex_super_input v-model="form.skuMaterial" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_brand')" prop="isBrand">
            <ex_super_input v-model="isBrand" type="radio-group" key="isBrand" class="w_fill" :attrs="{
      i18n: true,
      items: [{ _label: 'label_no_brand', _value: 'N' }, { _label: 'label_has_brand', _value: 'Y' }]
    }" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_is_electrify')" prop="isElectrify">
            <ex_super_input v-model="form.isElectrify" type="radio-group" key="isElectrify" class="w_fill" :attrs="{
      i18n: true,
      items: [{ label: 'YesOrNoEnum__Y', value: 'Y' }, { label: 'YesOrNoEnum__N', value: 'N' }]
    }" />
          </el-form-item>
        </el-col>
      </el-row>

      <!--     品牌 -->
      <el-row v-if="isBrand == 'Y'">
        <el-col>
          <el-form-item :label="$tt('label_sku_brand', '商品品牌')" prop="skuBrand">
            <ex_super_input v-model="form.skuBrand" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_model', '商品型号')" prop="skuModel">
            <ex_super_input v-model="form.skuModel" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="6">
          <el-form-item :label="$tt('label_sku_image', '商品图片')" prop="skuUrl">
            <!-- <ex_super_input ref="fileUpload" v-model="form.skuUrl" type="upload-img" key="skuUrl" :attrs="{
              headers: { targetFolder: '_public_', }
            }" /> -->
            <ex_super_upload type="image" v-model="form.skuUrl" :limit="1"
              onlySingle
							onlyUrl
              key="skuUrl" :limitTip="true" accept=".png,.jpg,.jpeg" :attrs="{
      headers: { targetFolder: '_public_', }
    }" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="6">
          <el-form-item :label="$tt('label_sku_quality_equirement', '质检要求')" prop="skuQualityCheckRequirement">
            <el-input type="textarea" v-model="form.skuQualityCheckRequirement"></el-input>
          </el-form-item>
          <el-form-item :label="$tt('label_sku_quality_way', '质检方式')" prop="skuQualityCheckType">
            <ex_super_input v-model="form.skuQualityCheckType" type="select" key="skuQualityCheckType" @change="changeQuality" enum="SkuQualityCheckTypeEnum"
              class="w_fill" />
          </el-form-item>
          <el-form-item v-if="form.skuQualityCheckType ==='SAMPLING'" :label="$tt('label_sku_sampling_ratio', '抽检比例')" prop="samplingRatio">
            <ex_super_input v-model="form.samplingRatio" append="%" appendClass="input_slot_div_mini"  />
          </el-form-item>
        </el-col> -->
      </el-row>

      <el-row>
        <el-col :span="2">
          <el-form-item :label="$tt('label_sku_link', '商品链接')" prop="skuDescUrl">
            <ex_super_input v-model="form.skuDescUrl" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="2">
          <el-form-item :label="$tt('label_remark', '备注')" prop="skuRemark">
            <el-input type="textarea" v-model="form.skuRemark"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <ex_header_spiler :title="$tt('label_declaration_info')"></ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_declared_categ_name_cn')" prop="skuDeclaredName">
            <ex_super_input v-model="form.skuDeclaredName" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_declared_categ_name_en')" prop="skuDeclaredNameEn">
            <ex_super_input v-model="form.skuDeclaredNameEn" />
          </el-form-item>
        </el-col>
        <el-col v-show="!$loginUser.ifElse英威特">
          <el-form-item label="HSCODE" prop="hsCode">
            <ex_super_input v-model="form.hsCode" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-show="!$loginUser.ifElse英威特">
        <el-col>
          <el-form-item :label="$tt('label_declared_value')" prop="skuDeclaredValue">
            <div style="display: flex; gap: 8px;">
              <ex_super_input v-model="form.skuDeclaredValue" />
              <FmsCurrencyChoose :value="form.currencyCode" @input="changeCurrency" @initList="initCurrency">
              </FmsCurrencyChoose>
            </div>
          </el-form-item>
        </el-col>
      </el-row>


      <ex_header_spiler :title="$tt('label_dimension_weight_spec')"></ex_header_spiler>
      <el-row>
        <el-col :span="1">
          <el-form-item :label="$tt('label_sku_weight_wordage', '重量')" prop="skuWeight">
            <ex_super_input v-model="form.skuWeight" append="kg" appendClass="input_slot_div_mini" />
          </el-form-item>

        </el-col>
        <el-col :span="2" class="lenWidHeiClass">
          <el-form-item style="display: flex;" :label="$tt('label_sku_length_width_height', '长*宽*高')" prop="skuLength">
            <ex_super_input v-model="form.skuLength" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
          <el-form-item prop="skuWidth">
            <ex_super_input v-model="form.skuWidth" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
          <el-form-item prop="skuHeight">
            <ex_super_input v-model="form.skuHeight" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
        </el-col>

      </el-row>
      <el-row>
        <el-col :span="1">
          <el-form-item :label="$tt('label_sku_full_load_weight_wordage', '外箱重量')" prop="fullLoadOuterBoxWeight">
            <ex_super_input v-model="form.fullLoadOuterBoxWeight" append="kg" appendClass="input_slot_div_mini" />
          </el-form-item>
        </el-col>
        <el-col :span="2" class="lenWidHeiClass">
          <el-form-item style="display: flex;" prop="fullLoadOuterBoxLength">
            <template v-slot:label>
              <span>
                <el-tooltip content="外箱长宽高 指的是 商品按箱规装满整箱的长宽高" placement="top" effect="light">
                  <i class="el-icon-question"></i>
                </el-tooltip>
                {{ $tt('label_sku_full_load_length_width_height', '外箱长*宽*高') }}
              </span>
            </template>
            <ex_super_input v-model="form.fullLoadOuterBoxLength" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
          <el-form-item prop="fullLoadOuterBoxWidth">
            <ex_super_input v-model="form.fullLoadOuterBoxWidth" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
          <el-form-item prop="fullLoadOuterBoxHeight">
            <ex_super_input v-model="form.fullLoadOuterBoxHeight" append="cm" appendClass="input_slot_div_mini" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_carton_spec')" prop="cartonSpec">
            <div style="display: flex; gap: 8px;">
              <ex_super_input v-model="form.cartonSpec" />
              <ex_super_input v-model="form.skuPackagingMethod" type="select" key="skuPackagingMethod"
                enum="SkuPackageMethodEnum" class="w_fill" />
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <ex_header_spiler :title="$tt('label_other')"></ex_header_spiler>
      <el-row v-show="!$loginUser.ifElse英威特">
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_return_method')" prop="skuReturnMethod">
            <ex_super_input v-model="form.skuReturnMethod" type="select" key="skuReturnMethod"
              enum="SkuReturnMethodEnum" class="w_fill" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$t('label_transport_goods')" prop="cargoPropertyCode">
            <transport_goods_select v-model="form.cargoPropertyCode" @changeItem="cargoPropertyChange" class="w_fill"></transport_goods_select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_national_version_of_commodity', '商品国家版本')" prop="skuCountryVersion">
            <ex_super_input v-model="form.skuCountryVersion" type="select" key="skuCountryVersion"
              enum="SkuCountryVersionEnum" class="w_fill" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_buyer', '采购员')" prop="purchaser">
            <ex_super_input v-model="form.purchaser" />
          </el-form-item>

        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_developer', '开发员(选品)')" prop="developer">
            <ex_super_input v-model="form.developer" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$tt('label_certificate')" prop="certificateUrl">
            <ex_super_upload type="file" v-model="form.certificateUrl" key="certificateUrl" :limit="10" :limitTip="true" accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.doc,.docx"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_instruction_book', '说明书')" prop="instructionUrl">
            <!-- <ex_super_input ref="fileUpload" v-model="form.instructionUrl" type="upload-file" key="instructionUrl" /> -->
            <ex_super_upload type="file" v-model="form.instructionUrl" :limit="10" key="instructionUrl" :limitTip="true" accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.doc,.docx"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_inspection_declaration', '检测报关资料')" prop="customsDeclarationUrl">
            <!-- <ex_super_input ref="fileUpload" v-model="form.customsDeclarationUrl" type="upload-file"
              key="customsDeclarationUrl" /> -->
            <ex_super_upload type="file" v-model="form.customsDeclarationUrl" key="customsDeclarationUrl" :limit="10" :limitTip="true" accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.doc,.docx"/>
          </el-form-item>
        </el-col>
      </el-row>
      <ex_header_spiler :title="$tt('label_pack_quality_inspection')"></ex_header_spiler>

      <el-row>
        <el-col :span="8">

          <el-form-item :label="$tt('label_sku_quality_equirement')" prop="samplingRatio">
            <div class="flex_row">
              <ex_super_input v-model="form.skuQualityCheckType" type="select" key="skuQualityCheckType"
                class="flex_cell" @change="changeQuality" enum="SkuQualityCheckTypeEnum" />
              <ex_super_input v-if="form.skuQualityCheckType === 'SAMPLING'" placeholder="label_sku_sampling_ratio"
                v-model="form.samplingRatio" append="%" style="width:130px;margin-left:10px ;" />
            </div>

          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_quality_inspection_method',)" prop="skuQualityCheckMethod">
            <ex_super_input v-model="form.skuQualityCheckMethod" type="select" key="skuQualityCheckMethod"
              enum="SkuQualityCheckMethodEnum" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_quality_inspection_content')" prop="skuQualityCheckContent">
            <ex_super_input v-model="form.skuQualityCheckContent" type="select" multiple key="skuQualityCheckContent"
              enum="SkuQulityCheckContentEnum" />
          </el-form-item>
        </el-col>

      </el-row>
    </el-form>

    <div class="float-botton-form-button-panel" :style="{ 'padding-left': '160px' }">
      <template v-if="form.id !== '' && form.status === 'FAIL_PROCESS'">
        <el-button type="primary" @click="skuSubmit('REPEAT_AUDIT')">{{ $t('label_retry_submit_examine') }}</el-button>
        <el-button @click="return_page_back">{{ $tt('label_cancel') }}</el-button>
      </template>
      <template v-else>
        <el-button type="primary" @click="skuSubmit('SAVE')" v-if="isCustomerSystem">{{ $tt('label_save') }}</el-button>
        <el-button type="primary" @click="skuSubmit('SAVE_AUDIT')">{{ $tt('label_submit') }}</el-button>
        <el-button @click="return_page_back">{{ $tt('label_cancel') }}</el-button>
      </template>
    </div>



  </div>
</template>
<script>

let default_obj = {
  cartonSpec: null,
  companyCode: null,//		string 	公司编号
  skuOnlyCode: null,//		string 	@NotBlank(message="sku编码不能为空")
  skuBarcode: null,//		string 	商品条形码（不唯一）英文字母需要统一转大写
  customerId: null,//		string 	客户ID
  customerCode: null,//		string 	客户编号
  skuName: null,//	string 	商品中文名称
  skuNameEn: null,//		string 	商品名称（EN）
  customNumber: null,//		string 	客户自定义编号（客户自己的商品编号映射我们系统的SKU）
  skuModel: null,//	string 	商品型号
  hsCode: null,//	string 	商品海关编码出口申报给海关的海关编码
  currencyCode: null,//		string 	label_declaration_currency人民币RMB/美元USD/日元JPY/欧元EUR/英镑GBP/港币HKD
  skuDeclaredValue: null,//			bigdecimal 	申报价值(USD)申报给海关的商品价值
  skuDeclaredName: null,//		string 	中文申报品名出口申报给海关的中文商品名称
  skuDeclaredNameEn: null,//		string 	英文申报品名出口申报给海关的英文商品名称
  skuPrice: null,//		bigdecimal 	商品单价
  skuUnit: null,//		string 	商品单位
  skuWeight: null,//			bigdecimal 	商品重量(KG)
  skuLength: null,//		bigdecimal 	长(CM)
  skuWidth: null,//		bigdecimal 	宽(CM)
  skuHeight: null,//		bigdecimal 	高(CM)
  skuUrl: null,//		,//		string 	商品图片地址
  skuDescUrl: null,//		string 	商品信息链接
  skuOrigin: null,//		string 	商品原产地
  skuMaterial: null,//		string 	商品材质
  skuBrand: null,//		string 	商品品牌
  skuRemark: null,//		string 	商品描述
  skuType: null,//		SkuTypeEnum 	LETTER:信封, PACKAGE:包裹
  skuPackagingMethod: 'BOX',//		SkuPackageMethodEnum 	BOX:箱, BALING:捆包, BAG:袋, BUCKET:桶
  skuStatus: null,//		SkuStatusEnum 	WAIT_SUBMIT:待提交, PENDING_PROCESS:待复核, WAIT_DELIVERY:待发货, DELIVERY:发货中, DISCARD:废弃, FAIL_PROCESS:审核驳回
  isCertificate: null,//			YesOrNoEnum 	Y:是, N:否
  isSnManage: null,//		YesOrNoEnum 	Y:是, N:否
  categList: [],
  categId: null,//		long 	二级品类
  skuPackagingRule: null,//			integer 	sku包装规则
  isOuterPackaging: null,//		YesOrNoEnum 	Y:是, N:否

  isUploadImg: null,//		YesOrNoEnum 	Y:是, N:否
  sharedSign: null,//		YesOrNoEnum 	Y:是, N:否
  sharedPrice: null,//			bigdecimal 	共享单价
  sharedTime: null,//		long 	共享时间
  version: null,//		long 	商品版本商品版本号
  isDelivery: null,//			YesOrNoEnum 	Y:是, N:否
  isElectrify: 'N',//		YesOrNoEnum 	Y:是, N:否
  volumeType: null,//		MeasurementEnum 	LARGE:大尺寸, MEDIUM:中尺寸, SMALL:小尺寸
  isReceipt: null,//		string 	收货情况
  customerName: null,//		string 	所属客户名称
  deliveryTime: null,//		long 	发货日期
  certificateUrl: [],//		string 	证书
  skuReturnMethod: null,

  skuQualityCheckRequirement: null, // 商品质检要求
  skuQualityCheckType: 'COMPLETE_INSPECTION', // SkuQualityCheckTypeEnum 商品质检方式: SAMPLING 抽检, COMPLETE_INSPECTION 全检
  samplingRatio: null, // 抽检比例全检为100%
  fullLoadOuterBoxLength: null, // 外箱外箱长
  fullLoadOuterBoxWidth: null, // 外箱外箱宽
  fullLoadOuterBoxHeight: null, // 外箱外箱高
  fullLoadOuterBoxWeight: null, // 外箱外箱重量
  instructionUrl: [], // 说明书地址信息集合
  customsDeclarationUrl: [], // 检测报关资料地址信息集合
  skuCountryVersion: null, // 商品国家版本
  purchaser: null, // 采购员
  developer: null, // 开发员(选品)
  cargoPropertyId: '',
  cargoPropertyCode: '',
  cargoPropertyName: '',
  skuQualityCheckContent:['SIZE']
}
import router_params from '@/mixin/router_params';
import FmsCurrencyChoose from '@/component/fms/fms-currency-choose.vue'
import role_system_mixin from '@/mixin/role_system_mixin';

export default {
  mixins: [router_params, role_system_mixin],
  components: { FmsCurrencyChoose },

  data() {
    return {
      edit: false,
      loading: false,

      isBrand: 'N',
      sku_categ_cascader: false,
      form: _.cloneDeep(default_obj),
      rules: {
        customerId: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_customer' },
        skuName: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_sku_name' },
        skuNameEn: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_sku_name_en' },
        skuBarcode: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_sku_code' },
        categList: { required: true, type: 'array', message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_categ_info' },
        categId: {
          required: true, trigger: 'blur', label: 'label_categ_info',
          validator: (r, v, cb) => {
            if (_.isEmpty(v) && r.required && !this.$loginUser.ifElse英威特) {
              cb(this.$tt('tip_can_no_empty'))
            } else {
              cb()
            }
          }
        },
        skuDeclaredValue: { required: this.$loginUser.ifElse澳越, label: 'label_declared_value', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'money', required: this.$loginUser.ifElse澳越, }) ? cb() : null, },
        skuLength: { required: true, label: 'label_length', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'dimen', required: true, }) ? cb() : null, },
        skuWidth: { required: true, label: 'label_width', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'dimen', required: true, }) ? cb() : null, },
        skuHeight: { required: true, label: 'label_height', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'dimen', required: true, }) ? cb() : null, },
        skuWeight: { required: true, label: 'label_weight', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'weight', required: true, }) ? cb() : null, },
        skuDeclaredName: { label: 'label_declared_categ_name_cn', required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
        skuDeclaredNameEn: { label: 'label_declared_categ_name_en', required: false, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
        cartonSpec: {
          required: false, trigger: 'blur', label: 'label_carton_spec',
          validator: (r, v, cb) => {
            if (_.isEmpty(v) && r.required) {
              cb(this.$tt('tip_can_no_empty'))
            } else if (!_.isEmpty(v) && !this.$reg.PureNumber(v)) {
              cb(this.$tt("tip_only_positive_pure_decimal"))
            } else {
              cb()
            }
          }
        },
        skuPrice: { required: true, label: 'label_unit_price', trigger: 'blur', validator: (r, v, cb) => this.$ruleStandard({ v, cb, type: 'money', required: true, }) ? cb() : null, },
        isElectrify: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_is_electrify', },
        hsCode: { required: false, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_hs_code', },
        currencyCode: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur', label: 'label_currency_kind', },
        samplingRatio: {
          required: true, trigger: 'blur', label: 'label_sku_sampling_ratio',
          validator: (r, v, cb) => {
            if(this.form.skuQualityCheckType !== 'SAMPLING'){
              cb()
              return
            }
            if (!this.$ruleStandard({ v, cb, type: "ratio", required: true, })) {
              return
            } else if (v > 100) {
              cb(this.$tt("tip_no_more_any", { type: 100 }))
            } else {
              cb()
            }
          }
        },
      },


    };
  },

  methods: {
    initCurrency(e) {
      const item = _.head(e)
      if (item && item.localCurrency && !this.form.currencyCode) {
        this.form.currencyCode = item.localCurrency
      } else {
      }
    },
    allCateg(e) {
      if (this.$loginUser.ifElse英威特) {
        this.form.categId = e[0].id
        this.form.categList = [{ categoryName: e[0].name, categoryId: e[0].id }]
      }
    },
    changeQuality(e) {
      if (e === 'COMPLETE_INSPECTION') this.form.samplingRatio = null
    },

    changeCurrency(e) {
      if (e) {
        this.form.currencyCode = e
      }
    },
    customerChange(e) {
      console.log(e)
      if (e) {
        this.form.customerId = e.customerId
        this.form.customerName = e.customerName
        this.form.customerCode = e.customerCode
      }
    },
    skuSubmit(e) {
      if ('SAVE' == e) {
        this.form.skuStatus = 'DRAFT'
      } else if ('SAVE_AUDIT' == e) {
        if (this.$loginUser.ifElse澳越) {
          this.form.skuStatus = 'WAIT_AUDIT'
        } else {
          this.form.skuStatus = 'ENABLE'
        }
      } else if ('REPEAT_AUDIT' == e) {
        if (this.$loginUser.ifElse澳越) {
          this.form.skuStatus = 'WAIT_AUDIT'
        } else {
          this.form.skuStatus = 'ENABLE'

        }
      }
      // this.form.certificateUrl = []
      this.submit()
    },

    init_data_default(into_params) {
      this.form = _.cloneDeep(default_obj)
      this.edit = !!into_params.edit
      if (this.edit) {
        if (into_params.id) {
          this.loading = true
          this.$ajax({
            url: this.$url['mms/skuDetail'],
            method: 'post',
            data: { id: into_params.id },
            success: (res) => {
              if (!res.data) return this.$message.error(this.$tt("label_data_loss"))

              if (into_params.copy) {
                delete res.data.id
                this.edit = false
              }
              this.form = res.data
              if(this.form.skuQualityCheckContent&& typeof this.form.skuQualityCheckContent === 'string'){
                this.form.skuQualityCheckContent = this.form.skuQualityCheckContent.split(',')
              }

              this.sku_categ_cascader = false
              this.$nextTick(() => {
                this.sku_categ_cascader = true
              })
              this.fixTabLabel()
            },
            complete: () => {
              this.loading = false
            }
          })
        }
      } else {
        this.sku_categ_cascader = true
      }
      this.fixTabLabel()
    },
    fixTabLabel() {
      if (this.edit && !!this.form.id) {
        this.$emit("tagModifyLabel", { _key: 'label_name_code', name: this.$tt('label_edit_sku'), code: this.form.skuName || "" })

      } else {
        this.$emit("tagModifyLabel", "label_add_sku")
      }
    },

    submit() {
      this.$formRulesValidate({
        formRef: this.$refs['form'],
        rules: this.rules,
        success: () => {
          this.$ajax({
            url: this.$url['mms/skuSaveUpdate'],
            method: 'post',
            type: 'json',
            loading: true,
            data: { ...this.form, skuQualityCheckContent:Array.isArray(this.form.skuQualityCheckContent)?this.form.skuQualityCheckContent.join(','):'' },
            success: (res) => {
              this.$message.success(this.$tt('tip_submit_success'))
              this.return_emit(null, "reload")
              this.return_page_back()
            }
          })
        }
      })

    },
    cargoPropertyChange(item={id:null,code:null,name:null}) {
      console.log(item)
      this.$set(this.form,'cargoPropertyId',item.id)
      this.$set(this.form,'cargoPropertyCode',item.code)
      this.$set(this.form,'cargoPropertyName',item.name)
    }
  }
};

</script>
<style>
.lenWidHeiClass {
  display: flex;
  gap: 8px;
}

.lenWidHeiClass .el-form-item__content {
  display: inline-block !important;
  margin-left: 0 !important;
}
</style>
